<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-1.12.4.js"></script>
    <script>
        $(function () {
            $("button").click(function () {
                $.ajax({
                    url: 'http://localhost:8080/hello',
                    dataType: 'json',
                    success: function (r) {
                        alert(r.username + "," +r.age);
                    },
                    error: function (xhr) {
                        console.log(xhr);
                    }
                })
            });
        });
    </script>
</head>
<body>
<button>查看数据</button>

</body>
</html>